package net.qiqb.core.executing;

import net.qiqb.core.domain.EntityIdGeneratorRegistrar;
import net.qiqb.core.domain.annotation.EntityIdGenerator;
import org.picocontainer.MutablePicoContainer;

/**
 *
 */

public class EntityIdGeneratorHolder {

    private static EntityIdGeneratorRegistrar entityIdGeneratorRegistrar;


    public static <ID> EntityIdGenerator<ID> get(Class<ID> idClazz) {
        return entityIdGeneratorRegistrar.get(idClazz);
    }

    public static  <ID> ID generate(Class<ID> idClazz) {
        return get(idClazz).generate();
    }

    public static void setContainer(MutablePicoContainer container) {
        EntityIdGeneratorHolder.entityIdGeneratorRegistrar = container.getComponent(EntityIdGeneratorRegistrar.class);
    }
}
